Skip to content

fix(db): type the integer columns of applications, node relations and page contents - #3203

Open
rubenvdlinde wants to merge 1 commit into
feat/noid/app-menu-export-importfrom
fix/noid/entity-addtype-names
Open

rubenvdlinde wants to merge 1 commit into
feat/noid/app-menu-export-importfrom
fix/noid/entity-addtype-names

Conversation

@rubenvdlinde

@rubenvdlinde rubenvdlinde commented Nov 2, 2026 •

Copy link
Copy Markdown

Sits on #3138 (menu export and import), though the bug is older and on main too. Context, ContextNodeRelation and PageContent now register their field types under the property names, so the integer types they declare actually apply.

Size: 119 lines: 12 code and 107 tests.

What was wrong

Entity::addType() takes a property name: Entity::setter() and QBMapper::getParameterTypeForProperty() both look the type up by property. These three entities registered theirs under the column names (owner_type, context_id, node_id, node_type, page_id, node_rel_id), so:

  • getFieldTypes() listed six names that are not properties, and no type for ownerType, contextId, nodeId, nodeType, pageId and nodeRelId
  • the mapper bound those columns as strings when inserting and updating

Values read back from the database were already integers, because the properties are typed ?int and PHP converts a numeric string on assignment. A non-numeric value would still throw a TypeError there instead of being cast.

What changes

The six addType() calls use the property names. Context had the same pattern for owner_type, so it's included.

How it was tested

On Nextcloud 34 with PostgreSQL, new tests/unit/Db/EntityFieldTypesTest.php:

  • every field type of the three entities names a property, and the integer properties are typed integer
  • the mapper binds those properties as IQueryBuilder::PARAM_INT
  • a node relation and a page content written to the database and read back give integers

Without the change, the first two fail for all three entities (6 of 7 tests). The full unit suite passes on PostgreSQL (620 tests). composer cs:check, psalm and rector are all clean.

🖼️ Screenshots

No UI changes.

🏁 Checklist

  • ⛑️ Tests (unit and/or integration) are included or not needed
  • 🔙 Backport requests are created or not needed: /backport to stableX.X
  • 📅 Milestone is set
  • 🌸 PR title is meaningful (if it should be in the changelog: is it meaningful to users?)

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

… page contents

`Context`, `ContextNodeRelation` and `PageContent` registered their
field types under the column names (`owner_type`, `context_id`,
`node_id`, `node_type`, `page_id`, `node_rel_id`), while the entity
looks them up by property name. The casts never applied and the mapper
bound these columns as strings. They are now registered by property
name.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
@rubenvdlinde
rubenvdlinde force-pushed the feat/noid/app-menu-export-import branch from 2471ff4 to 6368c26 Compare November 4, 2026 12:35
@rubenvdlinde
rubenvdlinde force-pushed the fix/noid/entity-addtype-names branch from 05b7968 to 2f29f7a Compare November 4, 2026 12:36
@rubenvdlinde
rubenvdlinde marked this pull request as ready for review November 6, 2026 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant